<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        a, button {
            margin: 10px;
        }
    </style>
    <script>
        function msg(...args) {
            let msg = document.getElementById("msg")
            let d = ''
            for (let i = 0; i < args.length; i++) {
                d += ' ' + args[i]
            }
            msg.innerText = d
        }

        let count = 0;

        function sendMessage() {
            let messageData = document.getElementById("messageData").value;
            window.chrome.webview.postMessage(messageData);
            window.chrome.webview.postMessage(document.body.innerHTML);
        }

        ipc.on("test", function (stringdata, bool, float, int) {
            console.log('test-data:', stringdata, bool, float, int)
            msg("test:",stringdata, bool, float, int)
        })

        ipc.on("test-return", function (data) {
            msg("test-return:", data)
            //return data + " " + new Date().getTime().toString()
        })

        function ipcEmit() {
            ipc.emit('emit-name', ["杨红岩", "age", Math.random() + count], function (str1, str2, num3, result) {
                msg(str1, str2, num3, result)
            });
            count++
        }

        let set = null;

        function autoIpcEmit() {
            if (set == null) {
                set = setInterval(function () {
                    ipc.emit("emit-name", ["杨红岩", "age", Math.random() + count], function (str1, str2, num3, result) {
                        msg(str1, str2, num3, result)
                    });
                    count++
                }, 0)
            } else {
                clearInterval(set)
                set = null
            }
        }
        function showDevtools() {
            ipc.emit("showDevtools")
        }
        function executeDevToolsMethod() {
            ipc.emit("executeDevToolsMethod")
        }

        function cookieVisited() {
            ipc.emit("cookieVisited")
        }
        function cookieDelete() {
            ipc.emit("cookieDelete")
        }
        function setCookie() {
            ipc.emit("setCookie")
        }
    </script>
</head>
<body>
<p>
<h1>debug</h1>
<img src="menu_exit.png">
</p>
<a href="https://www.baidu.com">百度</a><br>
<button onclick="sendMessage()">sendMessage</button>
<input id="messageData" value="SetTitleText value">
<br>
<button onclick="ipcEmit()">emit</button>
<button onclick="autoIpcEmit()">auto emit</button>
<button onclick="showDevtools()">show devtools</button>
<button onclick="executeDevToolsMethod()">execute DevTools Method</button>
<button onclick="cookieVisited()">cookie visited</button>
<button onclick="cookieDelete()">cookie delete</button>
<button onclick="setCookie()">cookie set</button>
<p>
    <a href="https://gitee.com/energye/assets/releases/download/cli/energy-windows-64.zip">download:
        energy-windows-64.zip</a>
    <a href="http://chrome.360.cn/html5_labs/demos/dnd/">drag-file: to drag-file url</a>
</p>
<div id="msg"></div>
</body>
</html>